package com.yami.shop.api.controller;

import com.yami.shop.bean.app.dto.NoticeDto;
import com.yami.shop.bean.model.Notice;
import com.yami.shop.service.NoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/p/notice")
@Api(tags = "首页活动轮播图接口")
public class HomeNoticeController {
    @Autowired
    private MapperFacade mapperFacade;

    @Autowired
    private NoticeService noticeService;

    /**
     * 首页轮播图接口
     */
    @GetMapping("/homeNotice")
    @ApiOperation(value = "首页公告", notes = "获取首页公告列表信息")
    public ResponseEntity<List<NoticeDto>> homePicture() {
        Long shopId = Long.valueOf(0);
        List<Notice> noticeList = noticeService.listNotice(shopId);
        List<NoticeDto> noticeDtos = mapperFacade.mapAsList(noticeList, NoticeDto.class);
        return ResponseEntity.ok(noticeDtos);
    }
}
